package com.hxci.zc.controller;

import com.hxci.zc.domain.Student;
import com.hxci.zc.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("stu")
public class StudentController {
    @Autowired
    StudentService service;

    @RequestMapping("query")
    public String query(Model model){
        List<Student> list = service.list();
        System.out.println(list);
        model.addAttribute("list",list);
        return "student";
    }


    @RequestMapping("add")
    public String add(){
        Student stu = new Student();
        stu.setName("李四");
        stu.setSno("666");
        service.save(stu);
        return null;
    }
}
